/*
 * UserServiceImpl.java
 *
 * Copyright 2012 xwwx, Inc. All rights reserved.
 * 
 */
package com.xwwx.service.impl;

import java.util.List;

import com.xwwx.common.PageList;
import com.xwwx.common.Pages;
import com.xwwx.dao.UserDao;
import com.xwwx.exception.XwwxException;
import com.xwwx.pojo.User;
import com.xwwx.service.UserService;

/*
* @author  xwwx
* @version 1.0, 2012-11-13
* @since   JDK1.6
* 
* 用户服务实现类
*/
public class UserServiceImpl implements UserService{

	/** 用户数据库操作对象 **/
	private UserDao userDao;
	
	/** 根据用户名密码返回用户对象 **/
	@Override
	public User getUserByIdAndPwd(String userid, String password){

		return userDao.getUserByIdAndPwd(userid, password);
	}

	
	/** 得到全部用户 **/
	public PageList getUserList(String orderby, String ascordesc,Pages pages,String wherestr){
		
		PageList pl = new PageList();
		pages.setTotalNum(this.getAllUserNum(wherestr));
		pages.executeCount();
		List list = this.getUserDao().getUserList(orderby, ascordesc, pages.getPerPageNum(),pages.getPage(),wherestr);
		pl.setObjectList(list);
		pl.setPages(pages);
		
		return pl;
	}
	
	/** 得到用户数量 **/
	public long getAllUserNum(String wherestr) {
		return this.getUserDao().getAllUserNum(wherestr);
	}
	
	/** 分页得到用户列表  **/
	public  PageList getUserListFy(String orderby, String ascordesc,
			int pagesize, int page,String wherestr) throws XwwxException{
		
		return this.getUserDao().getUserListFy(orderby, ascordesc, pagesize, page, wherestr);
	}
	
	public UserDao getUserDao() {
		return userDao;
	}

	public void setUserDao(UserDao userDao) {
		this.userDao = userDao;
	}
	
}
